package com.huabo.system.service.impl;

import com.hbfk.util.PageInfo;
import com.huabo.system.config.DateBaseConfig;
import com.huabo.system.mysql.entity.TblMonitorModelMySql;
import com.huabo.system.mysql.mapper.TblMonitorModelMySqlMapper;
import com.huabo.system.oracle.entity.TblMonitorModel;
import com.huabo.system.oracle.mapper.TblMonitorModelMapper;
import com.huabo.system.service.TblMonitorModelService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class TblMonitorModelServiceImpl implements TblMonitorModelService {

    @Resource
    private TblMonitorModelMapper tblMonitorModelMapper;

    @Resource
    private TblMonitorModelMySqlMapper tblMonitorModelMySqlMapper;


    @Override
    public Map<String, Object> findByModelJKZX(String solutionid, PageInfo<TblMonitorModel> pageInfo) {
        if (DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblMonitorModelMapper.findByModelJKZX(solutionid, pageInfo));
            pageInfo.setTotalRecord(tblMonitorModelMapper.findByModelJKZXCount(solutionid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("data", pageInfo);
            return resultMap;
        } else {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblMonitorModelMySqlMapper.findByModelJKZX(solutionid, pageInfo));
            pageInfo.setTotalRecord(tblMonitorModelMySqlMapper.findByModelJKZXCount(solutionid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("data", pageInfo);
            return resultMap;
        }
    }
}
